{% extends "upload/upload-index.html" %}
{% load blog_tags %}

{% block content %}

<table class="layui-table">
    <colgroup>
        <col width="80">
        <col width="800">
        <col>
        <col>
        <col width="300">
    </colgroup>
    <thead>
    <tr>
        <th>选择</th>
        <th>文件名称</th>
        <th>修改时间</th>
        <th>文件大小</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {% for data in file_list %}
    <tr>
        <td>
            <input type="checkbox" name="file" value="{{ data.id }}">
        </td>
        <td>{{ data.file_name }}</td>
        <td>{{ data.upload_time }}</td>
        <td>{{ data.upload_size }}</td>
        <td>
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail"
               href="{% url 'blog:file-info' data.id %}">查看</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"
               href="{% url 'blog:delete-file' data.id %}">删除</a>
            <a class="layui-btn layui-btn-xs" lay-event="edit" href="{% url 'blog:download' %}">下载</a>
        </td>
    </tr>
    {% endfor %}

    </tbody>
</table>

<div class="layui-box layui-laypage layui-laypage-molv" id="layui-laypage-3">
    {% if page_obj %}
        <a href="?page=1" class="layui-laypage-last" title="" data-page="1">首页</a>
        {% if page_obj.has_previous %}
            <a href="?page={{ page_obj.previous_page_number }}" class="layui-laypage-prev" data-page="">上一页</a>
        {% else %}
            <a class="layui-laypage-prev layui-disabled" data-page="">上一页</a>
        {% endif %}

        {% for num in paginator.page_range %}  # 循环遍历页码列表，并展示到底部
            {% if num == page_obj.number %}
                <span class="layui-laypage-curr"><em class="layui-laypage-em"style="background-color:#1E9FFF;"></em><em>{{ num }}</em></span>
            {% else %}
                <a href="?page={{ num }}" data-page="{{ num }}">{{ num }}</a>
            {% endif %}
        {% endfor %}


        {% if page_obj.has_next %}
            <a href="?page={{ page_obj.next_page_number }}" class="layui-laypage-next" data-page="">下一页</a>
        {% else %}
            <a class="layui-laypage-next layui-disabled" data-page="">下一页</a>
        {% endif %}
        <a href="?page={{ paginator.num_pages }}" class="layui-laypage-last" title="" data-page="{{ paginator.num_pages }}">尾页</a>
    {% endif %}
</div>


{% endblock %}